The present invention relates to the field of computer systems. More particularly, the invention relates to a method and system for executing a query involving a partitioned database object.
A xe2x80x9cqueryxe2x80x9d is a statement or collection of statements that is used to access a database. Specialized query languages, such as the structured query language (xe2x80x9cSQLxe2x80x9d) are often used to interrogate and access a database. Many types of queries include at least the following. First, the identity of the database object(s) being accessed to execute the query (e.g., one or more named database tables). If the query accesses two or more database objects, what is the link between the objects (e.g., a join condition or column). The typical query also defines selection criteria, which is often referred to as a matching condition, filter, or predicate. Lastly, a query may define which fields in the database object are to be displayed or printed in the result.
A query may seek to access a partitioned database object. Partitioning in a database system generally refers to the process of decomposing an object into a greater number of relatively smaller objects. Smaller objects are often easier to manage and more efficient to search than larger objects. Thus, database systems utilize partitioning to decompose objects such as tables and indexes into smaller and more manageable pieces or xe2x80x9cpartitions.xe2x80x9d
One approach to evaluating a query on partitioned data is to treat each partition as a separate schema object. In this approach, some or all of the query is independently evaluated for each partition, and this process is iteratively performed for each partition until the entire query has been evaluated for all partitions to be accessed. Since each partition is independently evaluated, data processed or temporarily created for a first partition may be discarded or overwritten when evaluating a subsequent partition. However, certain categories of queries may require subsequent processing to use data that was created for a prior partition. This may occur, for example, if the query involves a blocking operation, in which no partition can be completely processed until data from all the relevant partitions have been accessed for the blocking operation.
The present invention provides a method and mechanism to execute a query against a partitioned database object, in which data processed or created for an earlier partition is maintained even after further processing is performed against a subsequent partition. In one embodiment of the invention, a shared data object, such as a context object, is maintained to store data from processing the partitions of a partitioned table. Rather than discarding or overwriting the shared data object after processing each partition, the data from a subsequent partition is instead appended to the shared data object. In this manner, data from all relevant partitions exists for later use. Further details of aspects, objects, and advantages of the invention are described below in the detailed description, drawings, and claims.